package com.ruoyi.web.controller.yada;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import com.ruoyi.system.domain_yada.OceanTemperatureVO;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.IOceanTemperatureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 海洋表面温度监测
 */
@Api(tags = "海洋表面温度监测")
@RestController
@RequestMapping(value = "/business-service/api/Ocean", produces = "application/json;charset=UTF-8")
public class OceanTemperatureController {
    @Resource
    private IOceanTemperatureService temperatureService;

    /**
     * 查询方法
     * @return 参数类
     */
    @RequestMapping(value = "/selectOcean",method = {RequestMethod.GET})
    @ApiOperation(value = "查询方法",httpMethod = "GET")
    public AjaxResult selectOcean(@RequestBody OceanTemperatureVO temperatureVO)
    {
        List<OceanTemperatureVO> eastVOSList= temperatureService.selectOcean(temperatureVO.getStartDate());
        return AjaxResult.success(eastVOSList);
    }

    /**
     * 删除方法
     * @param ID id
     * @return 状态码
     */
    @RequestMapping(value = "/DelOcean",method = {RequestMethod.DELETE})
    @ApiOperation(value = "删除方法",httpMethod = "DELETE")
    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)

    public AjaxResult DelOcean(@Param("ID") String ID)
    {
        int NUM = temperatureService.DelOcean(ID);
        if (NUM>0)
        {
            return AjaxResult.success();
        }
        return  AjaxResult.error();

    }

    /**
     * 新增方法
     * @param eastVOS 新增实体类
     * @return 状态码
     */
    @ApiOperation(value = "新增方法",httpMethod = "POST")
    @RequestMapping(value = "/IntoAustralia",method = {RequestMethod.POST})
    public AjaxResult IntoOcean(@RequestBody  OceanTemperatureVO eastVOS)
    {
        eastVOS.setCreateTime(LocalDateTime.now());
        int NUM =  temperatureService.IntoOcean(eastVOS);
        if (NUM>0)
        {
            return AjaxResult.success();
        }
        return  AjaxResult.error();
    }
}
